package com.jiliang.jiliangserver.controller;


import com.jiliang.jiliangserver.domain.*;
import com.jiliang.jiliangserver.model.AjaxResult;
import com.jiliang.jiliangserver.model.page.TableDataInfo;
import com.jiliang.jiliangserver.service.JiliangService;
import com.jiliang.jiliangserver.service.MaterialService;
import com.jiliang.jiliangserver.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/jiliang")
@Slf4j
public class JiliangController extends BaseController {

    @Autowired
    private JiliangService jiliangService;


    /**
     * 创建消息
     * @param message
     * @return
     */
    @PostMapping("/createMessage")
    public AjaxResult createBattery(@RequestBody JlMessage message)throws Exception{
        jiliangService.createMessage(message);
        return AjaxResult.success();
    }

    /**
     * 更新消息
     * @param message
     * @return
     */
    @PutMapping("/updateMessage")
    public AjaxResult updateMessage(@RequestBody JlMessage message)throws Exception{
        jiliangService.updateMessage(message);
        return AjaxResult.success();
    }


    /**
     * 条件查询消息列表
     * @return
     */
    @GetMapping("/selectMessageList")
    public TableDataInfo selectMessageList(JlMessage message){
        startPage();
        List<JlMessage>  Messages = jiliangService.selectMessageList(message);
        return getDataTable(Messages);
    }

    /**
     * 查询消息id
     * @return
     */
    @GetMapping("/selectMessageById")
    public AjaxResult selectMessageById(Long id){
        JlMessage jlMessage = jiliangService.selectMessageById(id);
        return AjaxResult.success(jlMessage);
    }

    /**
     * 根据字典类型查询字典数据信息
     */
    @GetMapping(value = "/getDictByType")
    public AjaxResult getDictByType( String dictType)
    {
        List<Map> maps = jiliangService.getDictByType(dictType);
        return success(maps);
    }



}






